//
//  downLoadPdf.m
//  Estate
//
//  Created by heyong on 16/8/22.
//  Copyright © 2016年 ttsx. All rights reserved.
//

#import "downLoadPdfCell.h"

@implementation downLoadPdfCell
- (UIImageView *)leftImg{
    if(!_leftImg){
        _leftImg=[[UIImageView alloc]init];
    }
    return _leftImg;
}

- (UIButton *)downBtn{
    if(!_downBtn){
        _downBtn=[[UIButton alloc]init];
    }
    return _downBtn;
}

-(UILabel *)title{
    if(!_title){
        _title=[[UILabel alloc]init];
    }
    return _title;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self= [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self initSubView];
    }
    return self;
}

- (void)initSubView{
    [self addSubview:self.leftImg];
    self.selectionStyle=UITableViewCellSelectionStyleNone;
    
    self.leftImg.image=[UIImage imageNamed:@"shutiao2"];
    [self addSubview:self.downBtn];
    [self.downBtn addTarget:self action:@selector(clickDetail) forControlEvents:UIControlEventTouchUpInside];
    if(self.isLook){
        [self.downBtn setImage:[UIImage imageNamed:@"chakan_1"] forState:UIControlStateNormal];
        [self.downBtn setImage:[UIImage imageNamed:@"chakan_1"] forState:UIControlStateSelected];
        
    }else{
        [self.downBtn setImage:[UIImage imageNamed:@"xiazai_1"] forState:UIControlStateNormal];
        [self.downBtn setImage:[UIImage imageNamed:@"xiazai_1"] forState:UIControlStateSelected];
    }
    [self addSubview:self.title];
    self.title.font=[UIFont systemFontOfSize:16*BIZ];
    self.title.textColor=UIColorFromRGB(0x787878);
    self.title.numberOfLines = 0;
    
}


- (void)clickDetail{
    if(self.detailBlick){
        self.detailBlick();
    }
}


- (void)setTitleContent:(NSString *)title
{
    _title.text = title;
    _title.frame=CGRectMake(kPaddingLeftWidth,0 , (kScreen_Width - kPaddingLeftWidth*2)-30, [downLoadPdfCell cellHeightWithObj:_title.text ]);
    //设置竖条
    _leftImg.frame=CGRectMake(0, 1,3,[downLoadPdfCell cellHeightWithObj:_title.text]);
    //设置按钮
    CGFloat mWidth = [UIScreen mainScreen].bounds.size.width - 60;
    _downBtn.frame=CGRectMake(mWidth+5, 2, 50, 50);
}

+ (CGFloat)cellHeightWithObj:(NSString *)string{
    CGFloat cellHeight = 44;
    CGFloat mWidth = [UIScreen mainScreen].bounds.size.width - 100;
    cellHeight = [string boundingRectWithSize:CGSizeMake(mWidth,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin  attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16*BIZ]} context:nil].size.height;
    if(cellHeight<=44){
        return 44;
    }else{
        return cellHeight;
    }
}

+ (CGFloat)cellContentHeight:(NSString *)contents
{
    return  2*2  + [downLoadPdfCell cellHeightWithObj:contents];
}

@end
